// 资产经营管理模块接口
import request from '@/http/request'
const apiUrl = 'bf-assets'

// -----------资产库相关接口----------
export const assetsApi = {
    getAssetsPage: (param) => request.post(`${apiUrl}/assets/getAssetsPage`, param), // 分页查询资产信息
    addAssets: (param) => request.post(`${apiUrl}/assets/addAssets`, param), // 资产信息录入
    updateAssets: (param) => request.post(`${apiUrl}/assets/updateAssets`, param), // 资产信息编辑保存
    getAssetsStatistics: () => request.get(`${apiUrl}/assets/getAssetsStatistics`), // 查询资产总数
    assetsDelete: (param) => request.post(`${apiUrl}/assets/delete`,param), // 资产删除
    getAssetsDetail: (id) => request.get(`${apiUrl}/assets/getAssetsDetail?assetsId=${id}`), // 资产详情
    getLocations: (type,code) => { // 查询区域街道  type：1区域 2街道 ； code：位置类型为2时 必传
        if (code) {
            return request.get(`${apiUrl}/location/getLocations?type=${type}&code=${code}`)
        } else {
            return request.get(`${apiUrl}/location/getLocations?type=${type}`)
        }
    },
}

// -----------房源库相关接口----------
export const housingApi = {
    
    getHousingPage: (param) => request.post(`${apiUrl}/housing/getHousingPage`, param), // 分页查询房源信息
    getHousingStatistics: () => request.get(`${apiUrl}/housing/getHousingStatistics`), // 查询房源总数
    getHousingList: (id) => request.get(`${apiUrl}/housing/getHousingList?assetsId=${id}`), // 房源明细
    getFreeHousingList: (param) => request.get(`${apiUrl}/housing/getFreeHousingList`,{params:param}), // 房源明细
    getFreeHousingList2: (param) => request.post(`${apiUrl}/housing/getFreeHousingList2`,param), // 房源明细
    housingDelete: (param) => request.post(`${apiUrl}/housing/delete`,param), // 房源删除
    getHousingDetail: (id) => request.get(`${apiUrl}/housing/getHousingDetail?housingId=${id}`), // 房源详情
    updateHousing: (param) => request.post(`${apiUrl}/housing/updateHousing`, param), // 房源信息编辑保存
    addHousing: (param) => request.post(`${apiUrl}/housing/addHousing`, param), // 房源信息录入
    getAssetsList: (name) => request.get(`${apiUrl}/assets/getAssetsList?assetsName=${name}`), // 选择房源所属资产
}

// -----------客户库相关接口----------
export const customerApi = {
    getCustomerPage: (param) => request.post(`${apiUrl}/customer/getCustomerPage`, param), // 分页查询客户
    getCustomerStatistics: () => request.get(`${apiUrl}/customer/getCustomerStatistics`), // 查询客户数
    getBank: (id) => request.get(`${apiUrl}/bank/getBankBy?associationId=${id}`), // 查看银行账户
    customerAdd: (param) => request.post(`${apiUrl}/customer/add`, param), // 新增租赁客户
    getCustomerInfo: (customerId) => request.get(`${apiUrl}/customer/getinfo/${customerId}`), // 编辑时获取客户信息
    customerEdit: (customerId,param) => request.post(`${apiUrl}/customer/updateOne/${customerId}`, param), // 新增租赁客户
}

// -----------物业库相关接口----------
export const propertyApi = {
    getPropertyCompanyPage: (param) => request.post(`${apiUrl}/property/company/getPropertyCompanyPage`, param), // 分页查询物业
    getPropertyCompanyStatistics: () => request.get(`${apiUrl}/property/company/getPropertyCompanyStatistics`), // 查询物业数
    getPropertyCompanyList: (param) => request.get(`${apiUrl}/property/company/getPropertyCompanyList?propertyCompanyName=${param}`), // 查询物业数
    saveProperty: (param) => request.post(`${apiUrl}/property/company/save`,param), // 新增/编辑物业
    getPropertyInfo: (id) => request.get(`${apiUrl}/property/company/getInfo?propertyCompanyId=${id}`), // 查询物业详情
}

// -------------文件--------------
export const fileControlApi = {
  ledgerManagement: (param) => request.post(`/bf-bidding/ledgerManagement/export`,param,{ responseType: 'blob' }), // 台账导出
    fileDelete: (id, urlKey) => request.get(`${apiUrl}/file/delete?associationId=${id}&urlKey=${urlKey}`), // 文件删除
    fileDownload: (name, urlKey) => request.get(`${apiUrl}/file/download?fileName=${name}&urlKey=${urlKey}`), // 文件下载
    uploadDocumentFile: (param) => request.post(`${apiUrl}/file/upload/document`,param), // 上传文件 文档类型
    uploadDocumentFile2: (param) => request.post(`${apiUrl}/file/upload/document/contract`,param), // 上传文件 文档类型
    uploadImgFile: (param) => request.post(`${apiUrl}/file/upload/img`,param), // 上传文件 图片类型
    uploadContractFile: (param) => request.post(`${apiUrl}/file/upload/assets/contract`,param), // 上传合同的附件
}

// -----------合同相关接口----------
export const contractApi = {
    getContractTemplates: (param) => request.post(`${apiUrl}/contract/getContractTemplates`, param), // 查询合同模板列表
    contractPreview: (key) => request.get(`${apiUrl}/contract/preview/${key}`), // 预览合同模板
    contractUpdate: (param) => request.post(`${apiUrl}/contract/update`,param), // 更新合同模板
    getReplenishInfo:(param)=> request.get(`${apiUrl}/contract/getReplenishInfo?contractId=${param.contractId}`),// 查询补充信息
    saveReplenishInfo:(param)=> request.post(`${apiUrl}/contract/saveReplenishInfo`,param),//保存补充信息
    getCheckupInfo:(param)=> request.get(`${apiUrl}/contract/getCheckupInfo?contractId=${param.contractId}`),// 在审核列表获取会审信息
    getBindData:(param) => request.get(`${apiUrl}/contract/getBindData/${param.templateUrlKey}?contractId=${param.contractId}`),// 获取此合同模板下的已保存的html数据
    saveCheckupInfo:(param) => request.post(`${apiUrl}/contract/saveCheckupInfo`,param),// 提交审核
    getCheckupInfoByContractId:(param)=>request.get(`${apiUrl}/contract/getCheckupInfoByContractId?contractId=${param.contractId}`),// 在审核列表获取会审信息
    getContractFileListDto:(param)=>request.get(`${apiUrl}/contract/getContractFileListDto?contractId=${param.contractId}`),// 获取新增合同保存的图片
    batchContract:(param)=>request.post(`${apiUrl}/contract/batch`,param), // 确认合同
    getContractDraftVo:(param)=>request.get(`${apiUrl}/contract/getContractDraftVo`,{params:param}), // 获取新租合同信息
}

// -----------资产档案相关接口----------
export const assetFilesApi = {
    getAllAssetsFiles: (param) => request.post(`${apiUrl}/assetsFiles/getAllAssetsFiles`, param), // 分页查询资产档案
    statisticalArea: (param) => request.post(`${apiUrl}/assetsFiles/statisticalArea`, param), // 查询默认资产档案统计数据
    statisticalIdle: (param) => request.post(`${apiUrl}/assetsFiles/statisticalIdle`, param), // 查询空闲资产档案统计数据
    statisticalDueSoon: (param) => request.post(`${apiUrl}/assetsFiles/statisticalDueSoon`, param), // 查询即将到期资产档案统计数据
    getAssetsFileInfo: (assetsId) => request.get(`${apiUrl}/assetsFiles/getInfo/${assetsId}`), // 查询资产档案详情
    getContractHistoryPage: (param) => request.post(`${apiUrl}/assetsFiles/getContractHistoryPage`, param), // 获取合同历史
    getCollectionHistory: (param) => request.post(`${apiUrl}/assetsFiles/getCollectionHistory`, param), // 获取核收历史
    getAlertInfo: () => request.get(`${apiUrl}/assetsRemind/get`), // 获取提醒信息
    saveAlertInfo: (param) => request.post(`${apiUrl}/assetsRemind/save`, param), // 获取提醒信息
}

// -----------补充协议相关接口----------
export const supplementaryAgreementApi ={
    getInfo: (param) => request.get(`${apiUrl}/supplementaryAgreement/getInfo/${param.contractId}`), // 获取补充协议数据
    submit: (param) => request.post(`${apiUrl}/supplementaryAgreement/add`, param), // 提交审批
}

export const otherApi = {
    getCompanyBank: (param) => request.get(`${apiUrl}/bank/getCompanyBank`), // 获取公司收款账户信息
}

/**
* 开票管理
*/
export const invoiceApi = {
  getPageList: (param) => request.post("bf-finance/receipt/business/page/list", param),
  getBasicInfo: (param) => request.get(`${apiUrl}/leaseReceipt/baseInfo`, { params: param }),
  addInvoice: (param) => request.post("bf-finance/receipt/save", param),// 申请开票
  getInfo: (param) => request.get(`bf-finance/receipt/info`, { params: param }),// 详情
  exportTableFile: (param) => request.post(`bf-finance/receipt/business/export`, param, { responseType: "arraybuffer" }),// 导出
};
